package com.fr71.project.dm.service.impl;

import com.fr71.common.utils.DateUtils;
import com.fr71.framework.web.domain.AjaxResult;
import com.fr71.project.dm.domain.PdOrder;
import com.fr71.project.dm.mapper.PdOrderMapper;
import com.fr71.project.dm.service.IPdOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 开发者：https://github.com/devzwy
 * 创建时间：2023-06-28
 * 类描述：订单Service业务层处理
 */
@Service
public class PdOrderServiceImpl implements IPdOrderService {
    
    @Autowired
    private PdOrderMapper pdOrderMapper;

    /**
     * 查询订单
     * 
     * @param orderId 订单主键
     * @return 订单
     */
    @Override
    public PdOrder selectPdOrderByOrderId(String orderId) {
        return pdOrderMapper.selectPdOrderByOrderId(orderId);
    }

    /**
     * 查询订单列表
     * 
     * @param pdOrder 订单
     * @return 订单
     */
    @Override
    public List<PdOrder> selectPdOrderList(PdOrder pdOrder) {
        return pdOrderMapper.selectPdOrderList(pdOrder);
    }

    /**
     * 获取首页统计数据
     */
    @Override
    public AjaxResult getHomeData() {
        AjaxResult result = AjaxResult.success();
        result.put("total", pdOrderMapper.getTotal());
        result.put("yearTotal", pdOrderMapper.getTotalYear());
        result.put("monthTotal", pdOrderMapper.getTotalMonth());
        result.put("dayTotal", pdOrderMapper.getTotalDay());
        result.put("yearList", pdOrderMapper.getYearList());
        result.put("monthList", pdOrderMapper.getMonthList());
        result.put("dayList", pdOrderMapper.getDayList());
        result.put("hourList", pdOrderMapper.getHourList());
        return result;
    }

    /**
     * 新增订单
     * 
     * @param pdOrder 订单
     * @return 结果
     */
    @Override
    public int insertPdOrder(PdOrder pdOrder) {
        pdOrder.setCreateTime(DateUtils.getNowDate());
        return pdOrderMapper.insertPdOrder(pdOrder);
    }

    /**
     * 修改订单
     * 
     * @param pdOrder 订单
     * @return 结果
     */
    @Override
    public int updatePdOrder(PdOrder pdOrder) {
        pdOrder.setUpdateTime(DateUtils.getNowDate());
        return pdOrderMapper.updatePdOrder(pdOrder);
    }

    /**
     * 批量删除订单
     * 
     * @param orderIds 需要删除的订单主键
     * @return 结果
     */
    @Override
    public int deletePdOrderByOrderIds(String[] orderIds) {
        return pdOrderMapper.deletePdOrderByOrderIds(orderIds);
    }

    /**
     * 删除订单信息
     * 
     * @param orderId 订单主键
     * @return 结果
     */
    @Override
    public int deletePdOrderByOrderId(String orderId) {
        return pdOrderMapper.deletePdOrderByOrderId(orderId);
    }
}